<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Background Image Scroll Effect</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <style>
	  body {
	    margin: 0;
	    font-family: sans-serif;
	  }
	  
	  .bg-image {
	    width: 100%;
	    height: 100vh;
	    background: url("./bg.jpg");
	    background-position: center;
	    background-attachment: fixed;
	    background-size: 160%;
	  }
	  
	  .container {
	    padding: 100px;
	  }
	  
	  h1 {
	    font-size: 50px;
	  }
	  p {
	    color: grey;
	  }
	  
	  @media (max-width: 500px) {
	    .container {
	      padding: 10px;
	    }
	  }
  </style>
  <body>
    <div class="bg-image" id="bg-image"></div>
    <div class="container">
      <h1>Welcome to our website</h1>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae suscipit,
        provident veritatis quos dolorum repellendus officia voluptate veniam id
        pariatur, maiores dolore libero nemo repudiandae facere reiciendis
        quisquam? Deleniti, eius.
      </p>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae suscipit,
        provident veritatis quos dolorum repellendus officia voluptate veniam id
        pariatur, maiores dolore libero nemo repudiandae facere reiciendis
        quisquam? Deleniti, eius.
      </p>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae suscipit,
        provident veritatis quos dolorum repellendus officia voluptate veniam id
        pariatur, maiores dolore libero nemo repudiandae facere reiciendis
        quisquam? Deleniti, eius.
      </p>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae suscipit,
        provident veritatis quos dolorum repellendus officia voluptate veniam id
        pariatur, maiores dolore libero nemo repudiandae facere reiciendis
        quisquam? Deleniti, eius.
      </p>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae suscipit,
        provident veritatis quos dolorum repellendus officia voluptate veniam id
        pariatur, maiores dolore libero nemo repudiandae facere reiciendis
        quisquam? Deleniti, eius.
      </p>
      <p>
        Lorem ipsum dolor sit amet consectetur adipisicing elit. Quae suscipit,
        provident veritatis quos dolorum repellendus officia voluptate veniam id
        pariatur, maiores dolore libero nemo repudiandae facere reiciendis
        quisquam? Deleniti, eius.
      </p>
    </div>
  </body>
  <script>
	  const bgImageEl = document.getElementById("bg-image");
	  
	  window.addEventListener("scroll", () => {
	    updateImage();
	  });
	  
	  function updateImage() {
	    bgImageEl.style.opacity = 1 - window.pageYOffset / 900;
	    bgImageEl.style.backgroundSize = 160 - window.pageYOffset / 12 + "%";
	  }
  </script>
</html>